<template>
	<scroll-view scroll-y="true" class="cases-edit" v-if="casesInfo">
		<view class="part part1">
			<view class="flex-row-start p1">
				<view class="photo bg-cover" :style="{backgroundImage: 'url(https://cdn.yingpaipay.com/' + (casesInfo.sex == '2' ? 'man.png' : 'woman.png') + ')'}"></view>
				<view class="info">
					<view class="t1">{{casesInfo.patientName}}</view>
					<view>{{casesInfo.sex == '2' ? '男' : '女'}}<text class="t2">{{casesInfo.age}}岁</text></view>
				</view>
			</view>
			<view class="flex-row-between p2">
				<view>
					<text class="t">科室：</text>
					<text>{{casesInfo.departmentName}}</text>
				</view>
				<view>
					<text class="t">时间：</text>
					<text>{{casesInfo.visitTime}}</text>
				</view>
			</view>
		</view>
		
		<view class="part part2">
			<view class="name">病史信息</view>
			
			<view class="title">
				<view class="label">主诉</view>
			</view>
			<view class="conten">
				<view class="textarea-box">{{casesInfo.complaint}}</view>
			</view>
			
			<view class="title flex-row-between">
				<view class="label">现病史</view>
				<view v-show="casesInfo.presentIllness == '无'" class="label">无</view>
			</view>
			<view v-show="casesInfo.presentIllness != '无'" class="conten">
				<view class="textarea-box">{{casesInfo.presentIllness}}</view>
			</view>
			<view v-show="casesInfo.presentIllness == '无'" class="line"></view>
			
			<view class="title flex-row-between">
				<view class="label">既往史</view>
				<view v-show="casesInfo.pastHistory == '无'" class="label">无</view>
			</view>
			<view v-show="casesInfo.pastHistory != '无'" class="conten">
				<view class="textarea-box">{{casesInfo.pastHistory}}</view>
			</view>
			<view v-show="casesInfo.pastHistory == '无'" class="line"></view>
			
			<view class="title flex-row-between">
				<view class="label">过敏史</view>
				<view v-show="casesInfo.allergies == '无'" class="label">无</view>
			</view>
			<view v-show="casesInfo.allergies != '无'" class="conten">
				<view class="textarea-box">{{casesInfo.allergies}}</view>
			</view>
			<view v-show="casesInfo.allergies == '无'" class="line"></view>
			
		</view>
		
		<view class="part part3">
			<view class="name">体格检查</view>
			<view class="conten">
				<view class="textarea-box">{{casesInfo.pe || '无内容'}}</view>
			</view>
		</view>
		
		<view class="part part4">
			<view class="name">临床诊断</view>
			<view class="conten flex-row-start">
				<view class="sickness-t">诊断</view>
				<view class="flex-1 flex-row-start flex-wrap sickness-temp">
					<view class="items flex-row-center" v-for="(item, index) in casesInfo.diseasesName.split('|')" :key="index">
						<text>{{ item }}</text>
					</view>
				</view>
			</view>
		</view>
		
		<view class="part part5">
			<view class="name">病例资料<text class="t">(复诊记录、病例、处方和检查报告等)</text></view>
			<view v-show="fileList.length <= 0" class="conten">无内容</view>
			<view class="conten flex-row-start" ><image v-for="(item, index) in fileList" :key="index" class="img" :src="item" @click="previewImage(fileList,index)"></image></view>
		</view>
	</scroll-view>
</template>

<script>
	import uUploadImage from '@/components/u-upload-image/u-upload-image.vue';
	export default {
		components: { uUploadImage },
		data() {
			return {
				casesId: null, // 病历ID
				casesInfo: null, // 病历详情
				fileList: []
			}
		},
		onLoad(options) {
			this.casesId = options.id
			this.getInfo()
		},
		methods: {
			getInfo() {
				this.$api.getCasesInfo({
					params: {
						id: this.casesId
					}
				}).then(res => {
					if (res.code == 200) {
						this.casesInfo = res.result
						this.fileList = res.result.records ? res.result.records.split(',') : []
					} else {
						uni.showToast({
							title: res.message,
							icon: 'none'
						});
					}
				});
			},
		}
	}
</script>

<style lang="less" scoped>
@import './edit.less';
</style>
